package dyyx.cli;

import dyyx.util.CommUtil;
import dyyx.util.FileUtil;

public class FileCharsetConvertMain {
	
    public static void main(String[] args) throws Exception{ 
    	
    	int num = 0;
    	if(args!=null){
    		num = args.length;
    	}
    	if(num!=3){
    		throw new Exception("args error,file srcCharset destCharset");
    	}
    	String file = args[0];
    	String srcCharset = args[1];
    	String destCharset = args[2];
    	
    	System.out.println("file="+file);
    	System.out.println("srcCharset="+srcCharset);
    	System.out.println("destCharset="+destCharset);

    	
    	String str = CommUtil.read(file, srcCharset);
    	byte[]bytes = str.getBytes(destCharset);
    	FileUtil.write(file+"."+destCharset, bytes);
    	
    	System.out.println("convert done");
    	
    	


        
    }
    
   
}
